/**
 * ***********************************************************
 * Castor CodeGen 1.2.1 with SoNiC ME serialization patch:    
 * ***********************************************************
 * @author Adam Dec (SoNiC, snc85@o2.pl)
 * @since 14-12-2008
 * @update 14-02-2009
 * ***********************************************************
 * 
 * ***********************************************************
 * Changed Castor CodeGen 1.2 classes:
 *  - JType.java
 *  - CollectionMemberAndAccessorFactory.java
 *  - SourceFactory.java
 * ***********************************************************
 */

package com.sonic.mquotes.dto;

/**
 * Class MqQuoteMessage.
 * 
 * @version $Revision$ $Date$
 */
public class MqQuoteMessage implements de.enough.polish.io.Externalizable {


      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field _time.
     */
    private java.util.Date _time;

    /**
     * Field _sec_id.
     */
    private int _sec_id;

    /**
     * keeps track of state for field: _sec_id
     */
    private boolean _has_sec_id;

    /**
     * Field _elementList.
     */
    private java.util.Vector _elementList;


      //----------------/
     //- Constructors -/
    //----------------/

    public MqQuoteMessage() {
        super();
        this._elementList = new java.util.Vector();
    }


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * 
     * 
     * @param vElement
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addElement(
            final com.sonic.mquotes.dto.Element vElement)
    throws java.lang.IndexOutOfBoundsException {
        this._elementList.addElement(vElement);
    }

    /**
     * 
     * 
     * @param index
     * @param vElement
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addElement(
            final int index,
            final com.sonic.mquotes.dto.Element vElement)
    throws java.lang.IndexOutOfBoundsException {
        this._elementList.insertElementAt(vElement, index);
    }

    /**
     */
    public void deleteSec_id(
    ) {
        this._has_sec_id= false;
    }

    /**
     * Method enumerateElement.
     * 
     * @return an Enumeration over all
     * com.sonic.mquotes.dto.Element elements
     */
    public java.util.Enumeration enumerateElement(
    ) {
        return this._elementList.elements();
    }

    /**
     * Method getElement.
     * 
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     * @return the value of the com.sonic.mquotes.dto.Element at
     * the given index
     */
    public com.sonic.mquotes.dto.Element getElement(
            final int index)
    throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._elementList.size()) {
            throw new IndexOutOfBoundsException("getElement: Index value '" + index + "' not in range [0.." + (this._elementList.size() - 1) + "]");
        }
        
        return (com.sonic.mquotes.dto.Element) _elementList.elementAt(index);
    }

    /**
     * Method getElementCount.
     * 
     * @return the size of this collection
     */
    public int getElementCount(
    ) {
        return this._elementList.size();
    }

    /**
     * Returns the value of field 'sec_id'.
     * 
     * @return the value of field 'Sec_id'.
     */
    public int getSec_id(
    ) {
        return this._sec_id;
    }

    /**
     * Returns the value of field 'time'.
     * 
     * @return the value of field 'Time'.
     */
    public java.util.Date getTime(
    ) {
        return this._time;
    }

    /**
     * Method hasSec_id.
     * 
     * @return true if at least one Sec_id has been added
     */
    public boolean hasSec_id(
    ) {
        return this._has_sec_id;
    }

    /**
     * Reads data from byte stream.
     * 
     * @param dis
     * @throws java.io.IOException 
     */
    public void read(
            final java.io.DataInputStream dis)
    throws java.io.IOException {
        this._time = new java.util.Date(dis.readLong());
this._sec_id = dis.readInt();
this._has_sec_id = dis.readBoolean();
this._elementList = (java.util.Vector)de.enough.polish.io.Serializer.deserialize( dis );

    }

    /**
     */
    public void removeAllElement(
    ) {
        this._elementList.removeAllElements();
    }

    /**
     * Method removeElement.
     * 
     * @param vElement
     * @return true if the object was removed from the collection.
     */
    public boolean removeElement(
            final com.sonic.mquotes.dto.Element vElement) {
        boolean removed = _elementList.removeElement(vElement);
        return removed;
    }

    /**
     * Method removeElementAt.
     * 
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     * @return the element removed from the collection
     */
    public void removeElementAt(
            final int index)
    throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._elementList.size()) {
            throw new IndexOutOfBoundsException("removeElementAt: Index value '" + index + "' not in range [0.." + (this._elementList.size() - 1) + "]");
        }
        
        this._elementList.removeElementAt(index);
    }

    /**
     * 
     * 
     * @param index
     * @param vElement
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void setElement(
            final int index,
            final com.sonic.mquotes.dto.Element vElement)
    throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._elementList.size()) {
            throw new IndexOutOfBoundsException("setElement: Index value '" + index + "' not in range [0.." + (this._elementList.size() - 1) + "]");
        }
        
        this._elementList.setElementAt(vElement, index);
    }

    /**
     * Sets the value of field 'sec_id'.
     * 
     * @param sec_id the value of field 'sec_id'.
     */
    public void setSec_id(
            final int sec_id) {
        this._sec_id = sec_id;
        this._has_sec_id = true;
    }

    /**
     * Sets the value of field 'time'.
     * 
     * @param time the value of field 'time'.
     */
    public void setTime(
            final java.util.Date time) {
        this._time = time;
    }

    /**
     * Writes data to byte stream.
     * 
     * @param dos
     * @throws java.io.IOException 
     */
    public void write(
            final java.io.DataOutputStream dos)
    throws java.io.IOException {
        dos.writeLong( this._time.getTime() );
dos.writeInt( this._sec_id );
dos.writeBoolean( this._has_sec_id );
de.enough.polish.io.Serializer.serialize( this._elementList, dos );

    }

}
